﻿using System;
using System.Text;
using System.Drawing;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;

public static partial class glDRIVE
{
    /*
    函数 gl.inv
    矩阵求逆
    参数 a: a[n,n]原矩阵。返回逆矩阵。
    参数 n: 矩阵阶数
    返回值 若矩阵奇异，则返回标志值0，否则返回标志值非0。
    */

    public static string drive_inv()
    {
        int i, j;
        double[,] a = new double[4, 4]{
            {0.2368,0.2471,0.2568,1.2671},
            {1.1161,0.1254,0.1397,0.1490},
            {0.1582,1.1675,0.1768,0.1871},
            {0.1968,0.2071,1.2168,0.2271}
        };
        double[,] b = new double[4, 4];
        for (i = 0; i <= 3; i++)
            for (j = 0; j <= 3; j++) b[i, j] = a[i, j];
        i = gl.inv(b, 4);
        if (i == 0) return "error 0";
        return gl.html_table("实矩阵 A:", a) +
               gl.html_table("逆矩阵 A-:", b);

    }
}